home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 436_01 / indefs.h < prev    next >
Text File  |  1994-10-07  |  10KB  |  290 lines

  1. /*************************************************************************
  2.     Header file:  INDEFS.H
  3.  
  4.     Contains directives, definitions, and macros used by INCON.LIB.
  5.  
  6.     Compiler:  Borland Turbo C 2.01
  7.  
  8.     INCON source files and the object and library files created from
  9.     them are:
  10.         Copyright (c) 1993-94, Richard Zigler.
  11.     You may freely distribute unmodified source, object, and library
  12.     files, and incorporate them into your own non-commercial software,
  13.     provided that this paragraph and the program name and copyright
  14.     strings defined in INCON.C are included in all copies.
  15. *************************************************************************/
  16.  
  17. #if !defined(IN_DEFS)
  18. #define IN_DEFS
  19.  
  20. /**** Model-dependent Pointer Types ****/
  21.  
  22. #if defined( __TINY__ ) || defined( __SMALL__ ) || defined( __MEDIUM__ )
  23. typedef char near *        pCHAR;
  24. #else
  25. typedef char far *        pCHAR;
  26. #endif
  27.  
  28. /**** Data Type Synonyms ****/
  29.  
  30. typedef unsigned char    BYTE;
  31. typedef unsigned short    WORD;
  32. typedef unsigned long    DWORD;
  33. typedef short                FLAG;                /* int-size true/false flag        */
  34. typedef char                BFLAG;            /* byte-size true/false flag        */
  35.  
  36. #define NO                    0
  37. #define YES                    1
  38.  
  39. /**** Keyboard Macros ****/
  40.  
  41. #define KEYREAD            (bioskey(0))    /* read keyboard buffer                */
  42. #define KEYREADY            (bioskey(1))    /* check for key in buffer            */
  43. #define KEYSTATUS            (bioskey(2))    /* get k/b shift key flags            */
  44.  
  45. /**** Shift Key Masks ****/
  46.  
  47. #define R_SHIFT            0x01                /* [Right Shift] down                */
  48. #define L_SHIFT            0x02                /* [Left Shift] down                    */
  49. #define CTRL_KEY            0x04                /* [Ctrl] down                            */
  50. #define ALT_KEY            0x08                /* [Alt] down                            */
  51. #define SCR_LOCK            0x10                /* [Scroll Lock] on                    */
  52. #define NUM_LOCK            0x20                /* [Num Lock] on                        */
  53. #define CAP_LOCK            0x40                /* [Caps Lock] on                        */
  54. #define INS_MODE            0x80                /* [Ins] mode active                    */
  55.  
  56. /**** BIOS Video Services ****/
  57.  
  58. #define GET_ATTR            0x08                /* reads char/attr at cursor        */
  59. #define WRITE_MANY        0x09                /* write char/attr n times            */
  60. #define BIOS_VIDEO        0x10
  61.  
  62. /**** BIOS Cursor Services ****/
  63.  
  64. #define ACT_PAGE            0x00                /* active video page                    */
  65. #define CUR_SIZE            0x01                /* set cursor size                    */
  66. #define CUR_SET            0x02                /* set cursor position                */
  67. #define CUR_GET            0x03                /* read cursor type/position        */
  68. #define CUR_OFF            0x2000            /* turn off cursor                    */
  69.  
  70. /**** Switches for Cursor() ****/
  71.  
  72. static enum                    CurSwitch        /* cursor switch                        */
  73.                                 {
  74.                                 OFF        ,        /* switch off                            */
  75.                                 ON            ,        /* switch on                            */
  76.                                 SAVE        ,        /* save location                        */
  77.                                 RESTORE    ,        /* restore to location                */
  78.                                 }            ;
  79.  
  80. /**** Maximum Video Mode 3 Columns *****/
  81.  
  82. #define MAXCOL                80
  83.  
  84. /**** Input Field Delimiters ****/
  85.  
  86. #define L_DELIM            '['                /* normal delimiter, left            */
  87. #define R_DELIM            ']'                /* normal delimiter, right            */
  88. #define L_CONT                '<'                /* continuation delimiter, left    */
  89. #define R_CONT                '>'                /* continuation delimiter, right    */
  90.  
  91. /**** Do NOT remove the curls from around ERROR_BEEP, you idiot!!!    ****/
  92.  
  93. #define ERROR_BEEP    { sound(698) ; delay(80) ; nosound() ; }
  94.  
  95. /**** Data Macros ****/
  96.  
  97. #define LOBYTE(x)            ((x) & 0x00FF)    /* get low byte of int                */
  98. #define HIBYTE(x)            ((x) & 0xFF00)    /* get high byte of int                */
  99.  
  100. #if !defined(INCON_BUFFER)
  101. #define INCON_BUFFER        255                /* default buffer size                */
  102. #endif
  103.  
  104. /**** InCon Edit Keys ****/
  105. /* Do not include these     */
  106. /* keys in the extended- */
  107. /* key list.                 */
  108. /*************************/
  109.  
  110. /**** Cursor Movement ****/
  111.  
  112. #define HOME                0x47                /* [Home]:  start of input field    */
  113. #define LEFT                0x4B                /* [LeftArrow]:  character left    */
  114. #define RIGHT                0x4D                /* [RightArrow]: character right    */
  115. #define END                    0x4F                /* [End]:  end of input field        */
  116. #define C_LEFT                0x73                /* [^LeftArrow]:  word left        */
  117. #define C_RIGHT            0x74                /* [^RightArrow]:  word right        */
  118.  
  119. /**** Character Deletion ****/
  120.  
  121. #define C_L                    0x0C                /* [^L]:  word left                    */
  122. #define C_R                    0x12                /* [^R]:  word right                    */
  123. #define C_END                0x75                /* [^End]:  to end of field        */
  124. #define C_HOME                0x77                /* [^Home]: to start of field        */
  125. #define DEL                    0x53                /* [Del]:  character at cursor    */
  126. #define BS                    0x08                /* [BackSpace]:  character left    */
  127.  
  128. /**** Other Edit Keys ****/
  129.  
  130. #define K_MINUS            0x4A                /* [Keypad -]                            */
  131. #define K_PLUS                0x4E                /* [Keypad +]                            */
  132. #define CR                    0x0D                /* [Enter]:  end of input            */
  133. #define ESC                    0x1B                /* [Esc]:  clear input field        */
  134.  
  135. /**** Special-case Extended Key (see INCON.DOC) ****/
  136.  
  137. #define TAB                    0x09
  138.  
  139. /****
  140.     Bit field and union declarations for flags.  See the file INCON.DOC
  141.     for a discussion of the action of each flag.
  142. ****/
  143.  
  144. typedef struct
  145.             {
  146.             unsigned            Template    : 1;    /* treat default as template        */
  147.             unsigned            Hide        : 1;    /* do not echo input                    */
  148.             unsigned            Scroll    : 1;    /* scroll field                        */
  149.             unsigned            xKeys        : 1;    /* trap extended keys                */
  150.             unsigned            Delimit    : 1;    /* display field delimiters        */
  151.             unsigned            Confirm    : 1;    /* confirm input                        */
  152.             unsigned            Display    : 1;    /* display template                    */
  153.             unsigned            Sign        : 1;    /* allow sign                            */
  154.             unsigned            Message    : 1;    /* enable run-time messages        */
  155.             unsigned            Strip        : 1;    /* strip template delimiters        */
  156.             unsigned            Justify    : 2;    /* field justification                */
  157.             unsigned            Type        : 3;    /* input type                            */
  158.             unsigned            Debug        : 1;    /* display stats                        */
  159.             }                    BIT_FLAGS;
  160.  
  161. typedef union
  162.             {
  163.             WORD                iflags    ;        /* address flags as integer        */
  164.             BIT_FLAGS        bflags    ;        /* address flags as bit-field        */
  165.             }                    FLAGS        ;
  166.  
  167. /****
  168.     Structure and union declarations for message block.  See the file
  169.     INCON.DOC for a discussion of program parameters.
  170. ****/
  171.  
  172. typedef struct
  173.             {
  174.             WORD                BufOff    ;        /* input/output buffer offset        */
  175.             WORD                BufSeg    ;        /* input/output buffer segment    */
  176.             WORD                KeyOff    ;        /* extended-key list offset        */
  177.             WORD                KeySeg    ;        /* extended-key list segment        */
  178.             FLAGS                Flags        ;        /* flags union defined above        */
  179.             BYTE                Width        ;        /* field maximum width                */
  180.             BYTE                Prec        ;        /* field minimum entry/decimals    */
  181.             BYTE                Visible    ;        /* scrolling field visible len    */
  182.             BYTE                Attr        ;        /* field video attribute            */
  183.             BYTE                Fill        ;        /* field fill character                */
  184.             BYTE                Pad        ;        /* pad for justified/numeric        */
  185.             }                    SBLOCK    ;
  186.  
  187. typedef union
  188.             {                                        /* address message block as:        */
  189.             WORD                iblock[8];        /*  integer array                        */
  190.             SBLOCK            sblock    ;        /*  structure                            */
  191.             }                    MBLOCK    ;
  192.  
  193. /**** Flag Values ****/
  194.  
  195. #define FLAG_TEMPLATE    0x0001
  196. #define FLAG_HIDE            0x0002
  197. #define FLAG_SCROLL        0x0004
  198. #define FLAG_XKEYS        0x0008
  199. #define FLAG_DELIMIT        0x0010
  200. #define FLAG_CONFIRM        0x0020
  201. #define FLAG_DISPLAY        0x0040
  202. #define FLAG_SIGN            0x0080
  203. #define FLAG_MESSAGE        0x0100
  204. #define FLAG_STRIP        0x0200
  205. #define FLAG_NJUST        0x0000
  206. #define FLAG_LJUST        0x0400
  207. #define FLAG_CJUST        0x0800
  208. #define FLAG_RJUST        0x0C00
  209. #define FLAG_ALPHA        0x0000
  210. #define FLAG_UPPER        0x1000
  211. #define FLAG_INTGR        0x2000
  212. #define FLAG_FLOAT        0x3000
  213. #define FLAG_MIXED        0x4000
  214. #define FLAG_DEBUG        0x8000
  215.  
  216. /**** Flag Masks ****/
  217.  
  218. #define MASK_TEMPLATE    0x0001
  219. #define MASK_HIDE            0x0002
  220. #define MASK_SCROLL        0x0004
  221. #define MASK_XKEYS        0x0008
  222. #define MASK_DELIMIT        0x0010
  223. #define MASK_CONFIRM        0x0020
  224. #define MASK_DISPLAY        0x0040
  225. #define MASK_SIGN            0x0080
  226. #define MASK_MESSAGE        0x0100
  227. #define MASK_STRIP        0x0200
  228. #define MASK_JUSTIFY        0x0C00
  229. #define MASK_TYPE            0x7000
  230. #define MASK_DEBUG        0x8000
  231.  
  232. /**** Flag Shifts ****/
  233.  
  234. #define SHIFT_TEMPLATE     0
  235. #define SHIFT_HIDE         1
  236. #define SHIFT_SCROLL         2
  237. #define SHIFT_XKEYS         3
  238. #define SHIFT_DELIMIT     4
  239. #define SHIFT_CONFIRM     5
  240. #define SHIFT_DISPLAY     6
  241. #define SHIFT_SIGN         7
  242. #define SHIFT_MESSAGE     8
  243. #define SHIFT_STRIP         9
  244. #define SHIFT_JUSTIFY    10
  245. #define SHIFT_TYPE        12
  246. #define SHIFT_DEBUG        15
  247.  
  248. /****
  249.     Numeric values for multi-bit flags.  These values may be
  250.     combined with the masks and shifts to set individual flags.
  251. ****/
  252.  
  253. #define NJUST                0                    /* no justify